##########################################
# REPLICATION OF: 
#
# State Reach and Development in Africa since the 1960s: New data and analysis
#
# Political Science Research and Methods
#
# By Carl Müller-Crepon, 2021
#
##########################################

This replication directory contains all analysis files to replicate results and figures in the article. For replication, please run the file "replication.R". It will install all necessary packages, load all data, and source all files contained in the subdirectory "code". All tables, figures, and numbers contained in the original article and appendix are saved to the respective folders in "results". 

You can access the raw state reach data from this github reposity: https://github.com/carl-mc/state_reach_africa . 

Please cite: Müller-Crepon, Carl (2021). State Reach and Development in Africa since the 1960s: New data and analysis. Political Science Research and Methods, X(XX), xxx-xxx. 


Code files in "code" directory:
These files are, unless otherwise noted, sourced from the main file replication.R . 

analysis_main.R         Main analysis of education and infant mortality rates, as well as nightlight emissions
vor_vs_cells.R          Systematic comparison between voronoi cells and more typical quadratic raster cells
packages.R              Installs and loads all necessary packages
voronoi_functions.R     Functions needed to create voronoi polygons. Sourced from vor_vs_cells.R
plots_inputs.R          Plots input data for Appendix.
plots_statereach.R      Plots descriptives on state reach measures. 
functions.R             Main functions needed throughout the analysis.
descriptives.R          Makes descriptives of the data used in the main analysis. Sourced from analysis_main.R
analysis_leads.R        Analysis of leads (pseudo-parallel trends). Sourced from analysis_main.R
analysis_afrobarometer.R  Validation of state reach measure with Afrobaromenter enumeration area data. 
robcheck_plot.R         Plots of results of robustness checks. Sourced from analysis_main.R




Data files in "data" directory:

adminnum_bycountry.csv         Number of regions by country and year. Derived from
africa_regions_panel.GeoJSON   Main spatial panel data of African regions, their borders and capitals since countries independence.
data_educ.rds                  Main data for the analysis of primary education outcomes. Unit of analysis: Individual.
data_educ_mig.rds              Data for the robustness checks on differences among (non-)migrants.
data_enumarea_afrobaro.rds     Enumeration area data from Afrobarometer used to validate state reach measure.
data_infmort.rds               Main data for the analysis of infant mortality. Unit of analysis: Individual.
data_nightlight_***.rds        Data on nightlight emissions for voronoi cells of varying size (***, in km2). Used in Robustness checks. 
data_nightlightmain.rds        Main data for the analysis of nightlight emissions. Unit of analysis: Voronoi cell (400km2).
dist_natcap_bycountry.csv      Population-average distance to national capitals, over time, by country. 
dist_regcap_bycountry.csv      Population-average distance to regional capitals, over time, by country. 
lakes_uganda.GeoJSON           Lakes in Uganda from NaturalEarth, for plotting purposes.
michelin_extents.GeoJSON       Extent of each of the three Michelin map types, for plotting purposes.
michelin_tempcov.csv           Temporal coverage of Michelin maps, by map type.
nigeria_change_rs.rds          Contains a raster* object with changes in state reach in Nigeria, for plotting purposes
roadidx_bycountry.csv          Quality-weighted road index, by country over time
roadidx_continent.csv          Quality-weighted road index for all of Africa
statereach_change_dist.csv     Distributions of changes in state reach, by country
statereach_distribution.csv    Distributions of state reach, by country
statereach_natcap_****.tif     GeoTIFF raster of travel time to national capitals in years ****. Full data available at https://github.com/carl-mc/state_reach_africa
statereach_regcap_****.tif     GeoTIFF raster of travel time to regional capitals in years ****. Full data available at https://github.com/carl-mc/state_reach_africa
urbanization_bycountry.csv     Average urbanization rates, by country over time, from the World Bank.
voronoi_uga.GeoJSON            Voronoi polygons covering Uganda, for plotting purposes. 
 
 
 
Main Variables in analysis files:
(files: a = data_educ.rds, b = data_infmort.rds, c = data_nightlightmain.rds)

*Main Outcomes*
educ.prim         Dummy variable for whether an individual has been enrolled in primary school (only a)
dead              Dummy variable for whether a child has died under the age of 1 (only b)
nightlight.pc.log Nightlights per capita, logged (only c)

*Identifiers*
x, y, longnum, latnum   Geographic coordinates
pts.id            Point ID (a,b), voronoi cell ID (c)
cowcode           Correlates of War country code
year              Year. a: at age 6; b: at birth; c: at nightlight measurement
cow.year          cowcode x year factor
adm.id            Administrative unit ID
survey.id         DHS survey ID (a,b), for c, simply the year. 
adm.id.ind.year   ID of admin unit of pts.id at independence

*Main explanatory variables (a,b,c)*
natcap.ln         Log travel time to national capital, using time-variant road network and admin unit data
regcap.ln         Log travel time to regional capital, using time-variant road network and admin unit data
natcap.****       Log travel time to national capital, using time-invariant road network from year **** and time-variant admin unit data
regcap.****       Log travel time to regional capital, using time-invariant road network from year **** and time-variant admin unit data

*Additional outcomes*
educ.num          Ordnial education scale from DHS (a)
educ_years        Number of years in school (a)
any_prenatal      Any prenatal professional care (b)
public.birth      Brith in public institution (b) 
any_assist        Any birth assistance (b)
assist_traditional  Birth assistance by traditional medical personnel (b)
nightlight.any    Any nightliht emission (c)

*Controls*
female            Female dummy (a,b)
age.num           Numeric age variable (a)
birthorder.num    Birthorder (b)
twin              Twin dummy (b)
mother.b.age      Mother's age at birth (b)
children          Number of children (a)
member.num        Number of household members (a)
is.natcap         Dummy for is close to / contains national capital
is.regcap         Dummy for is close to / contains national capital
population        Local population count, from HYDE data
eprincl           Ethnic inclusion, based on spatial overlap with GeoEPR
eprexcl           Ethnic exclusion, based on spatial overlap with GeoEPR
ecwar             Ethnic civil war, based on spatial overlap with GeoEPR
cumsum.ecwar      Years in ethnic civil war, based on spatial overlap with GeoEPR
timesince.ecwar   Time since last ethnic civil war, based on spatial overlap with GeoEPR
ma.int.donal, ma.int.eaton, ma.nat.donal, ma.nat.eaton : National and international Market Access, computed along the lines of Donaldson and Eaton (see Appendix). 
road.dens.*       Local road density of 1-6 (*) main road types. 
inradius.*.km20   Presence of 1-6 (*) road types in 20km local neighborhood. 




